<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" id="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no">
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title><%= title %></title>
    <link rel='stylesheet' href='/css/style.css' />
  </head>
  <body>
        <form id="loginForm">
          <div class="">

            <input type="text" placeholder="用户名" id="userName" name="userName" value="1">
            <input type="password" placeholder="密码" id="passWord" name="passWord" value="1">

            <button class="logoBut" type="button">登录</button>
          </div>
        </form>
  <script src="/js/zepto.min.js"></script>
  <script>
    $(function () {
        $('.logoBut').click(function () {
            if($('#userName').val()==''){
                alert('请输入用户名！')
            }else if($('#passWord').val()==''){
                alert('请输入密码！')
            }else {
                $.ajax({
                    type: "POST",
                    url:"/user/login",
                    data:$('#loginForm').serialize(),// 你的formid
                    error: function(request) {
                        alert('无法请求服务器,请稍后再试！');
                    },
                    success: function(data) {
                        if(data.code==100){
                            location.href='/index';
                        }else if(data.code==-1){
                            alert(data.message);
                        }else {
                            alert(data.code+data.message);
                        }
                    }
                });
            }
        })
    })
  </script>
  </body>
</html>
